package logic

import (
	"cart/cache"
	"context"

	"cart/cart"
	"cart/internal/svc"

	"github.com/zeromicro/go-zero/core/logx"
)

type CartPriceLogic struct {
	ctx    context.Context
	svcCtx *svc.ServiceContext
	logx.Logger
}

func NewCartPriceLogic(ctx context.Context, svcCtx *svc.ServiceContext) *CartPriceLogic {
	return &CartPriceLogic{
		ctx:    ctx,
		svcCtx: svcCtx,
		Logger: logx.WithContext(ctx),
	}
}

func (l *CartPriceLogic) CartPrice(in *cart.CartPriceRequest) (*cart.CartPriceResponse, error) {
	// todo: 购物车总计
	err := cache.CartPrice(int(in.UserId), int(in.GoodsId))
	if err != 0 {
		logx.Error("计算失败")

	}
	return &cart.CartPriceResponse{}, nil
}
